﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Coticula.Web.Models;

namespace Coticula.Web.Controllers
{
    public class WidgetsController : Controller
    {
        //
        // GET: /Widgets/ServerStatus

        public ActionResult ServerStatus()
        {
            DateTime lastServerConnect = SpecificData.LastServerConnect;
            var elapsed = DateTime.Now - lastServerConnect;
            ViewBag.ElapsedTime = string.Format("{0}:{1}:{2}", ((int)elapsed.TotalHours),elapsed.Minutes.ToString("00"),elapsed.Seconds.ToString("00"));
            ViewBag.ElapsedTimeInt = (int)elapsed.TotalSeconds;
            return PartialView();
        }

        public ActionResult ServerStatusAjax()
        {
            DateTime lastServerConnect = SpecificData.LastServerConnect;
            var elapsed = DateTime.Now - lastServerConnect;
            return Json(((int) elapsed.TotalSeconds), JsonRequestBehavior.AllowGet);
        }

    }
}
